Merge "(bug 40154) On action=info show where this page redirects to and whether it...
authorTheDJ <hartman.wiki@gmail.com>
Wed, 17 Oct 2012 19:37:56 +0000 (19:37 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 17 Oct 2012 19:37:56 +0000 (19:37 +0000)
1  2 
includes/actions/InfoAction.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

@@@ -58,22 -58,6 +58,22 @@@ class InfoAction extends FormlessActio
        public function onView() {
                $content = '';
  
 +              // Validate revision
 +              $oldid = $this->page->getOldID();
 +              if ( $oldid ) {
 +                      $revision = $this->page->getRevisionFetched();
 +
 +                      // Revision is missing
 +                      if ( $revision === null ) {
 +                              return $this->msg( 'missing-revision', $oldid )->parse();
 +                      }
 +
 +                      // Revision is not current
 +                      if ( !$revision->isCurrent() ) {
 +                              return $this->msg( 'pageinfo-not-current' )->plain();
 +                      }
 +              }
 +
                // Page header
                if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
                        $content .= $this->msg( 'pageinfo-header' )->parse();
                        '.mw-templatesUsedExplanation { display: none; }' );
  
                // Get page information
 -              $title = $this->getTitle();
 -              $pageInfo = $this->pageInfo( $title );
 +              $pageInfo = $this->pageInfo();
  
                // Allow extensions to add additional information
 -              wfRunHooks( 'InfoAction', array( &$pageInfo ) );
 +              wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );
  
                // Render page information
                foreach ( $pageInfo as $header => $infoTable ) {
                }
  
                // Page credits
 -              /*if ( $title->exists() ) {
 +              /*if ( $this->page->exists() ) {
                        $content .= Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $this->getContributors() );
                }*/
  
         * may add additional information in arbitrary positions. Array values are arrays with one
         * element to be rendered as a header, arrays with two elements to be rendered as a table row.
         *
 -       * @param $title Title object
 +       * @return array
         */
 -      protected function pageInfo( $title ) {
 -              global $wgContLang, $wgDisableCounters, $wgRCMaxAge;
 +      protected function pageInfo() {
 +              global $wgContLang, $wgRCMaxAge;
  
                $user = $this->getUser();
                $lang = $this->getLanguage();
                $id = $title->getArticleID();
  
                // Get page information that would be too "expensive" to retrieve by normal means
 -              $userCanViewUnwatchedPages = $user->isAllowed( 'unwatchedpages' );
 -              $pageCounts = self::pageCounts( $title, $userCanViewUnwatchedPages, $wgDisableCounters );
 +              $pageCounts = self::pageCounts( $title, $user );
  
                // Get page properties
                $dbr = wfGetDB( DB_SLAVE );
                        $this->msg( 'pageinfo-display-title' ), $displayTitle
                );
  
+               // Is it a redirect? If so, where to?
+               if ( $title->isRedirect() ) {
+                       $pageInfo['header-basic'][] = array(
+                               $this->msg( 'pageinfo-redirectsto' ),
+                               Linker::link( $this->page->getRedirectTarget() ) . ' ' .
+                               $this->msg( 'parentheses', Linker::link(
+                                       $this->page->getRedirectTarget(),
+                                       $this->msg( 'pageinfo-redirectsto-info' ),
+                                       array(),
+                                       array( 'action' => 'info' )
+                               ) )->text()
+                       );
+               }
                // Default sort key
                $sortKey = $title->getCategorySortKey();
                if ( !empty( $pageProperties['defaultsort'] ) ) {
                        $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
                );
  
 -              if ( !$wgDisableCounters ) {
 +              if ( isset( $pageCounts['views'] ) ) {
                        // Number of views
                        $pageInfo['header-basic'][] = array(
                                $this->msg( 'pageinfo-views' ), $lang->formatNum( $pageCounts['views'] )
                        );
                }
  
 -              if ( $userCanViewUnwatchedPages ) {
 +              if ( isset( $pageCounts['watchers'] ) ) {
                        // Number of page watchers
                        $pageInfo['header-basic'][] = array(
                                $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] )
                                ->numParams( count( $title->getRedirectsHere() ) )
                );
  
+               // Is it counted as a content page?
+               if ( $this->page->isCountable() ) {
+                       $pageInfo['header-basic'][] = array(
+                               $this->msg( 'pageinfo-contentpage' ),
+                               $this->msg( 'pageinfo-contentpage-yes' )
+                       );
+               }
                // Subpages of this page, if subpages are enabled for the current NS
                if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
                        $prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' );
                        );
                }
  
 +              if ( !$this->page->exists() ) {
 +                      return $pageInfo;
 +              }
 +
                // Edit history
                $pageInfo['header-edits'] = array();
  
         * Returns page counts that would be too "expensive" to retrieve by normal means.
         *
         * @param $title Title object
 -       * @param $canViewUnwatched bool
 -       * @param $disableCounter bool
 +       * @param $user User object
         * @return array
         */
 -      protected static function pageCounts( $title, $canViewUnwatched, $disableCounter ) {
 -              global $wgRCMaxAge;
 +      protected static function pageCounts( $title, $user ) {
 +              global $wgRCMaxAge, $wgDisableCounters;
  
                wfProfileIn( __METHOD__ );
                $id = $title->getArticleID();
                $dbr = wfGetDB( DB_SLAVE );
                $result = array();
  
 -              if ( !$disableCounter ) {
 +              if ( !$wgDisableCounters ) {
                        // Number of views
                        $views = (int) $dbr->selectField(
                                'page',
                        $result['views'] = $views;
                }
  
 -              if ( $canViewUnwatched ) {
 +              if ( $user->isAllowed( 'unwatchedpages' ) ) {
                        // Number of page watchers
                        $watchers = (int) $dbr->selectField(
                                'watchlist',
@@@ -783,6 -783,7 +783,6 @@@ XHTML id names
  'qbbrowse'       => 'Browse',
  'qbedit'         => 'Edit',
  'qbpageoptions'  => 'This page',
 -'qbpageinfo'     => 'Context',
  'qbmyoptions'    => 'My pages',
  'qbspecialpages' => 'Special pages',
  'faq'            => 'FAQ',
@@@ -1483,15 -1484,6 +1483,15 @@@ It already exists.'
  'addsection-preload'               => '', # do not translate or duplicate this message to other languages
  'addsection-editintro'             => '', # do not translate or duplicate this message to other languages
  'defaultmessagetext'               => 'Default message text',
 +'content-failed-to-parse'          => 'Failed to parse $2 content for $1 model: $3',
 +'invalid-content-data'             => 'Invalid content data',
 +'content-not-allowed-here'         => '"$1" content is not allowed on page [[$2]]',
 +
 +# Content models
 +'content-model-wikitext'   => 'wikitext',
 +'content-model-text'       => 'plain text',
 +'content-model-javascript' => 'JavaScript',
 +'content-model-css'        => 'CSS',
  
  # Parser/template warnings
  'expensive-parserfunction-warning'        => "'''Warning:''' This page contains too many expensive parser function calls.
@@@ -2465,7 -2457,7 +2465,7 @@@ Maybe you want to edit the description 
  'shared-repo'                       => 'a shared repository',
  'shared-repo-name-wikimediacommons' => 'Wikimedia Commons', # only translate this message to other languages if you have to change it
  'filepage.css'                      => '/* CSS placed here is included on the file description page, also included on foreign client wikis */', # only translate this message to other languages if you have to change it
 -'upload-disallowed-here'            => 'Unfortunately you cannot overwrite this image.',
 +'upload-disallowed-here'            => 'You cannot overwrite this file.',
  
  # File reversion
  'filerevert'                => 'Revert $1',
@@@ -3073,8 -3065,8 +3073,8 @@@ You may have a bad link, or the revisio
  'undeletedrevisions'           => '{{PLURAL:$1|1 revision|$1 revisions}} restored',
  'undeletedrevisions-files'     => '{{PLURAL:$1|1 revision|$1 revisions}} and {{PLURAL:$2|1 file|$2 files}} restored',
  'undeletedfiles'               => '{{PLURAL:$1|1 file|$1 files}} restored',
 -'cannotundelete'               => 'Undelete failed;
 -someone else may have undeleted the page first.',
 +'cannotundelete'               => 'Undelete failed:
 +$1',
  'undeletedpage'                => "'''$1 has been restored'''
  
  Consult the [[Special:Log/delete|deletion log]] for a record of recent deletions and restorations.",
@@@ -3396,7 -3388,6 +3396,7 @@@ cannot move a page over itself.'
  'immobile-target-namespace-iw' => 'Interwiki link is not a valid target for page move.',
  'immobile-source-page'         => 'This page is not movable.',
  'immobile-target-page'         => 'Cannot move to that destination title.',
 +'bad-target-model'             => 'The desired destination uses a different content model. Can not convert from $1 to $2.',
  'imagenocrossnamespace'        => 'Cannot move file to non-file namespace',
  'nonfile-cannot-move-to-file'  => 'Cannot move non-file to file namespace',
  'imagetypemismatch'            => 'The new file extension does not match its type',
@@@ -3742,7 -3733,6 +3742,7 @@@ This is probably caused by a link to a 
  # Info page
  'pageinfo-header'              => '-', # do not translate or duplicate this message to other languages
  'pageinfo-title'               => 'Information for "$1"',
 +'pageinfo-not-current'         => 'Information may only be displayed for the current revision.',
  'pageinfo-header-basic'        => 'Basic information',
  'pageinfo-header-edits'        => 'Edit history',
  'pageinfo-header-restrictions' => 'Page protection',
  'pageinfo-templates'           => 'Transcluded {{PLURAL:$1|template|templates}} ($1)',
  'pageinfo-footer'              => '-', # do not translate or duplicate this message to other languages
  'pageinfo-toolboxlink'         => 'Page information',
+ 'pageinfo-redirectsto'         => 'Redirects to',
+ 'pageinfo-redirectsto-info'    => 'info',
+ 'pageinfo-contentpage'         => 'Counted as a content page',
+ 'pageinfo-contentpage-yes'     => 'Yes',
  
  # Skin names
  'skinname-standard'    => 'Classic', # only translate this message to other languages if you have to change it
@@@ -1035,9 -1035,7 +1035,9 @@@ Example: [http://translatewiki.net/w/i.
  'explainconflict' => 'Appears at the top of a page when there is an edit conflict.',
  'storedversion' => 'This is used in an edit conflict as the label for the top revision that has been stored, as opposed to your version that has not been stored which is shown at the bottom of the page.',
  'yourdiff' => '',
 -'copyrightwarning' => 'Copyright warning displayed under the edit box in editor',
 +'copyrightwarning' => 'Copyright warning displayed under the edit box in editor
 +*$1 - ...
 +*$2 - ...',
  'longpageerror' => 'Warning displayed when trying to save a text larger than the maximum size allowed',
  'protectedpagewarning' => '{{Related|Semiprotectedpagewarning}}',
  'semiprotectedpagewarning' => '{{Related|Semiprotectedpagewarning}}',
@@@ -1062,36 -1060,6 +1062,36 @@@ Please report at [[Support]] if you ar
  'moveddeleted-notice' => 'Shown on top of a deleted page in normal view modus ([http://translatewiki.net/wiki/Test example]).',
  'edit-conflict' => "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.",
  'defaultmessagetext' => 'Caption above the default message text shown on the left-hand side of a diff displayed after clicking “Show changes” when creating a new page in the MediaWiki: namespace',
 +'content-failed-to-parse' => "Error message indicating that the page's content can not be saved because it is syntactically invalid. This may occurr for content types using serialization or a strict markup syntax.
 +*$1 – content model ({{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}})
 +*$2 – content format as MIME type (e.g. <tt>text/css</tt>)
 +*$3 – specific error message",
 +'invalid-content-data' => "Error message indicating that the page's content can not be saved because it is invalid. This may occurr for content types with internal consistency constraints.",
 +'content-not-allowed-here' => 'Error message indicating that the desired content model is not supported in given localtion.
 +* $1 is the human readable name of the content model: {{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}}
 +* $2 is the title of the page in question.',
 +
 +# Content models
 +'content-model-wikitext' => 'Name for the wikitext content model, used when decribing what type of content a page contains.
 +
 +This message is substituted in:
 +*{{msg-mw|Bad-target-model}}
 +*{{msg-mw|Content-not-allowed-here}}',
 +'content-model-text' => 'Name for the plain text content model, used when decribing what type of content a page contains.
 +
 +This message is substituted in:
 +*{{msg-mw|Bad-target-model}}
 +*{{msg-mw|Content-not-allowed-here}}',
 +'content-model-javascript' => 'Name for the JavaScript content model, used when decribing what type of content a page contains.
 +
 +This message is substituted in:
 +*{{msg-mw|Bad-target-model}}
 +*{{msg-mw|Content-not-allowed-here}}',
 +'content-model-css' => 'Name for the CSS content model, used when decribing what type of content a page contains.
 +
 +This message is substituted in:
 +*{{msg-mw|Bad-target-model}}
 +*{{msg-mw|Content-not-allowed-here}}',
  
  # Parser/template warnings
  'expensive-parserfunction-warning' => 'On some (expensive) [[MetaWikipedia:Help:ParserFunctions|parser functions]] (e.g. <code><nowiki>{{#ifexist:}}</nowiki></code>) there is a limit of how many times it may be used. This is an error message shown when the limit is exceeded.
@@@ -1893,7 -1861,7 +1893,7 @@@ This action allows editing of all of th
  'recentchanges-legend' => 'Legend of the fieldset of [[Special:RecentChanges]]',
  'recentchanges-summary' => 'Summary of [[Special:RecentChanges]].',
  'recentchanges-label-newpage' => 'Tooltip for {{msg-mw|newpageletter}}',
 -'recentchanges-label-minor' => 'Tooltip for {{msg-mw|newpageletter}}',
 +'recentchanges-label-minor' => 'Tooltip for {{msg-mw|minoreditletter}}',
  'recentchanges-label-bot' => 'Tooltip for {{msg-mw|boteditletter}}',
  'recentchanges-label-unpatrolled' => 'Tooltip for {{msg-mw|unpatrolledletter}}',
  'rcnote' => 'Used on [[Special:RecentChanges]].
@@@ -2921,8 -2889,6 +2921,8 @@@ Options for the duration of the page pr
  {{Identical|Reset}}',
  'undeleteinvert' => '{{Identical|Invert selection}}',
  'undeletecomment' => '{{Identical|Reason}}',
 +'cannotundelete' => 'Message shown when undeletion failed for some reason.
 +* <code>$1</code> is the combined wikitext of messages for all errors that caused the failure.',
  'undelete-search-title' => 'Page title when showing the search form in Special:Undelete',
  'undelete-search-submit' => '{{Identical|Search}}',
  'undelete-error' => 'Page title when a page could not be undeleted',
@@@ -3227,12 -3193,6 +3227,12 @@@ Parameters
  'immobile-target-namespace-iw' => "This message appears when attempting to move a page, if a person has typed an interwiki link as a namespace prefix in the input box labelled 'To new title'.  The special page 'Movepage' cannot be used to move a page to another wiki.
  
  'Destination' can be used instead of 'target' in this message.",
 +'bad-target-model' => 'This message is shown when attempting to move a page, but the move would change the page\'s content model.
 +This may be the case when [[mw:Manual:$wgContentHandlerUseDB|$wgContentHandlerUseDB]] is set to false, because then a page\'s content model is derived from the page\'s title.
 +* $1: The localized name of the original page\'s content model:
 +**{{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}}
 +* $2: The localized name of the content model used by the destination title:
 +**{{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}}',
  'fix-double-redirects' => 'This is a checkbox in [[Special:MovePage]] which allows to move all redirects from the old title to the new title.',
  'protectedpagemovewarning' => 'Related message: [[MediaWiki:protectedpagewarning/{{#titleparts:{{PAGENAME}}|1|2}}]]
  {{Related|Semiprotectedpagewarning}}',
@@@ -3511,7 -3471,6 +3511,7 @@@ See also {{msg-mw|Anonuser}} and {{msg-
  # Info page
  'pageinfo-title' => 'Page title for action=info. Parameters:
  * $1 is the page name',
 +'pageinfo-not-current' => 'Error message displayed when information for an old revision is requested. Example: [{{fullurl:Project:News|oldid=4266597&action=info}}]',
  'pageinfo-header-basic' => 'Table section header in action=info.',
  'pageinfo-header-edits' => 'Table section header in action=info.',
  'pageinfo-header-restrictions' => 'Table section header in action=info.',
  'pageinfo-templates' => 'The list of templates transcluded within the page. Parameters:
  * $1 is the number of templates transcluded within the page.',
  'pageinfo-toolboxlink' => "Information link for the page (like 'What links here', but to action=info for the current page instead)",
+ 'pageinfo-redirectsto' => 'Key for the row shown if this page is a redirect.',
+ 'pageinfo-redirectsto-info' => 'Text to put in parentheses for the link to the action=info of the redirect target.',
+ 'pageinfo-contentpage' => 'Key for the row shown if this page is counted as a content page',
+ 'pageinfo-contentpage-yes' => 'Yes, this page is a content page',
  
  # Skin names
  'skinname-standard' => '{{optional}}
@@@ -178,6 -178,7 +178,6 @@@ $wgMessageStructure = array
                'qbbrowse',
                'qbedit',
                'qbpageoptions',
 -              'qbpageinfo',
                'qbmyoptions',
                'qbspecialpages',
                'faq',
                'addsection-preload',
                'addsection-editintro',
                'defaultmessagetext',
 +              'content-failed-to-parse',
 +              'invalid-content-data',
 +              'content-not-allowed-here',
 +      ),
 +      'contentmodels' => array(
 +              'content-model-wikitext',
 +              'content-model-text',
 +              'content-model-javascript',
 +              'content-model-css',
        ),
        'parserwarnings' => array(
                'expensive-parserfunction-warning',
                'immobile-target-namespace-iw',
                'immobile-source-page',
                'immobile-target-page',
 +              'bad-target-model',
                'immobile_namespace',
                'imagenocrossnamespace',
                'nonfile-cannot-move-to-file',
        'info' => array(
                'pageinfo-header',
                'pageinfo-title',
 +              'pageinfo-not-current',
                'pageinfo-header-basic',
                'pageinfo-header-edits',
                'pageinfo-header-restrictions',
                'pageinfo-templates',
                'pageinfo-footer',
                'pageinfo-toolboxlink',
+               'pageinfo-redirectsto',
+               'pageinfo-redirectsto-info',
+               'pageinfo-contentpage',
+               'pageinfo-contentpage-yes',
        ),
        'skin' => array(
                'skinname-standard',
@@@ -3839,7 -3833,6 +3843,7 @@@ XHTML id names."
        'toolbar'             => 'Edit page toolbar',
        'edit'                => 'Edit pages',
        'parserwarnings'      => 'Parser/template warnings',
 +      'contentmodels'       => 'Content models',
        'undo'                => '"Undo" feature',
        'cantcreateaccount'   => 'Account creation failure',
        'history'             => 'History pages',